package com.ytjj.qmyx.admin.controller.imController;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.dto.ImCustomerServiceTimeDto;
import com.ytjj.qmyx.admin.model.response.ServiceTimeResponse;
import com.ytjj.qmyx.admin.model.vo.ImCustomerServiceTimeVO;
import com.ytjj.qmyx.admin.service.imService.ImCustomerServiceTimeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客服服务时间管理controller
 */
@RestController
@RequestMapping("/imServiceTime")
@Slf4j
public class ImCustomerServiceTimeController {

    @Autowired
    private ImCustomerServiceTimeService imCustomerServiceTimeService;


    /**
     * 增服务时间
     * 参数:serviceName,beginTime,endTime,servicePeriod,serviceGroupName
     */
    @PostMapping("/addServiceTime")
    public CommonResult addServiceTime(@RequestBody ImCustomerServiceTimeVO request){
        Integer count = imCustomerServiceTimeService.addServiceTime(request);
        if (count > 0){
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }

    /**
     * 删服务时间
     * 参数:id
     */
    @PostMapping("/deleteServiceTime")
    public CommonResult deleteServiceTime(@RequestBody ImCustomerServiceTimeVO request){
        Integer count = imCustomerServiceTimeService.deleteServiceTime(request);
        if (count > 0){
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }

    /**
     * 改服务时间
     * 参数:id,serviceName,beginTime,endTime,servicePeriod,serviceGroupName
     */
    @PostMapping("/updateServiceTime")
    public CommonResult updateServiceTime(@RequestBody ImCustomerServiceTimeVO request){
        Integer count = imCustomerServiceTimeService.updateServiceTime(request);
        if (count > 0){
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }

    /**
     * 查服务时间
     */
    @GetMapping("/selectServiceTime")
    public CommonResult selectServiceTime(){
        ServiceTimeResponse list = imCustomerServiceTimeService.selectServiceTime();
        return CommonResult.success(list);
    }
}
